using System;
using SlamCms.Data;

namespace SlamCms.Sample.Entities
{
	public class Event : ContentItem
	{
		public string Title { get; set; }
		public DateTime StartDate { get; set; }
		public DateTime EndDate { get; set; }
		public string Description { get; set; }
		public string PageContent { get; set; }
		public string ThumbnailImageUrl { get; set; }
		public string ThumbnailImageCaption { get; set; }
		public string Location { get; set; }
		public int? EventType { get; set; }
		public bool? AllDayEvent { get; set; }
		public bool? Recurrence { get; set; }
		public string RecurrenceData { get; set; }
		public string RecurrenceID { get; set; }
		public int? MasterSeriesItemID { get; set; }
		public bool ShowInTagBrowser { get; set; }

		public static string FormatEventDate(DateTime startTime, DateTime endTime, bool allDayEvent)
		{
			string eventDate = "";

			if (startTime.ToString("D") == endTime.ToString("D"))
				eventDate = startTime.ToString("D") + "<br />" + startTime.ToString("t") + (startTime.ToString("t") != endTime.ToString("t") ? " - " + endTime.ToString("t") : "");
			if (startTime == endTime)
				eventDate = startTime.ToString("D") + "<br />" + startTime.ToString("t");
			if (allDayEvent)
				eventDate = startTime.ToString("D");
			if (startTime.ToString("MMMM yyyy") == endTime.ToString("MMMM yyyy") && startTime.ToString("dd") != endTime.ToString("dd"))
				eventDate = startTime.ToString("MMMM dd") + " - " + endTime.ToString("dd") + ", " + startTime.ToString("yyyy");
			if (startTime.ToString("MMMM yyyy") != endTime.ToString("MMMM yyyy"))
				eventDate = startTime.ToString("MMMM dd") + " - " + endTime.ToString("MMMM dd") + ", " + startTime.ToString("yyyy");
			if (startTime.ToString("MMMM yyyy") != endTime.ToString("MMMM yyyy") && startTime.ToString("yyyy") != endTime.ToString("yyyy"))
				eventDate = startTime.ToString("MMMM dd yyyy") + " - " + endTime.ToString("MMMM dd yyyy");

			return eventDate;
		}
	}
}
